// 创建storage代理模版
class StorageProxy {
    storage = null
    constructor(storageModel) {
      this.storage = storageModel
    }

    // 存
    setItem(key, value) {
      this.storage.setItem(key, JSON.stringify(value))
    }

    // 取
    getItem(key) {
      return JSON.parse(this.storage.getItem(key))
    }

    // 删
    removeItem(key) {
      this.storage.removeItem(key)
    }

    // 清空
    clear() {
      this.storage.clear()
    }
}

// 导出session存储
export const storageSession = new StorageProxy(sessionStorage)
// 导出local存储
export const storageLocal = new StorageProxy(localStorage)
